package com.hw.pusher_example;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.hw.pusher.HWPushActivity;

public class MainActivity extends HWPushActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        FlutterEngine flutterEngine = FlutterEngine.
//        GeneratedPluginRegistrant.registerWith(getFlutterView());
//        handler.postDelayed(()-> handler.sendEmptyMessage(1), 3000);

        gIntent();
    }

    @Override
    protected void onResume() {
        super.onResume();
        gIntent();
    }

    @Override
    protected void onNewIntent(@NonNull Intent intent) {
        super.onNewIntent(intent);
        gIntent();
    }

    void gIntent() {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        // Scheme协议（push_scheme://com.hw.pusher_example/deeplink?）需要开发者自定义:请将com.hw.pusher_example,并参考AndroidManifest.xml进行配置
        intent.setData(Uri.parse("push_scheme://com.hw.pusher_example/deeplink?"));
        // 往intent中添加参数，用户可以根据自己的需求进行添加参数
        intent.putExtra("name", "abc");
        //        intent.putExtra("age", 180);
        // 必须带上该Flag
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        String intentUri = intent.toUri(Intent.URI_INTENT_SCHEME);
        // 打印出的intentUri值就是设置到推送消息中intent字段的值
        Log.d("intentUri", intentUri);
    }

}
